<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
{{template "common/link.html" .}}
</head>
<body>
<div class="container demo-1">
    <div class="content" style="padding-top: 0px !important;">
        <div id="large-header" class="large-header">
            <canvas id="demo-canvas"></canvas>
            <div class="logo_box">
                <h3>欢迎你</h3>
                <form action="#" name="f" method="post">
                    <div class="input_outer">
                        <span class="u_user"></span>
                        <input name="username" class="text" style="color: #FFFFFF !important" type="text"
                               placeholder="请输入11位手机号码">
                    </div>
                    <div class="input_outer">
                        <span class="us_uer"></span>
                        <input name="password" class="text"
                               style="color: #FFFFFF !important; position:absolute; z-index:100;" value=""
                               type="password" placeholder="请输入密码">
                    </div>
                    <div class="input_outer">
                        <span class="us_uer"></span>
                        <input name="repassword" class="text"
                               style="color: #FFFFFF !important; position:absolute; z-index:100;" value=""
                               type="password" placeholder="确认密码">
                    </div>
                    <div class="input_outer">
                        <span class="uc_uer"></span>
                        <input name="code" class="text"
                               style="width:150px!important;color: #FFFFFF !important; position:absolute; z-index:100;"
                               value="" type="text" placeholder="手机验证码">
                        <a href="javascript:;" class="layui-inline layui-btn layui-btn-sm layui-btn-radius "
                           id="sendBtn">发送验证码</a>
                    </div>
                    <div class="mb2">
                        <a id="sub" lay-filter="sub" class="act-but submit" href="javascript:;" style="color: #FFFFFF">注册</a>
                    </div>
                    <div class="mb2" style="text-align: center">
                        已有账号？去
                        <a id="reg" href="/user" style="color: #86e685;">登录</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- /container -->
</body>
<script src="/static/js/TweenLite.min.js"></script>
<script src="/static/js/EasePack.min.js"></script>
<script src="/static/js/rAF.js"></script>
<script src="/static/js/demo-1.js"></script>
<script>
    //加载弹出层组件
    layui.use('layer', function () {
        var layer = layui.layer;
        //注册的点击事件
        $("#sub").on("click", function () {
            register();
        })

        $("body").keydown(function () {
            if (event.keyCode == "13") {
                register();
            }
        })

        //注册函数
        function register() {
            var username = $(" input[ name='username' ] ").val();
            var password = $(" input[ name='password' ] ").val();
            var repassword = $(" input[ name='repassword' ] ").val();
            var code = $(" input[ name='code' ] ").val();
            $.ajax({
                url: "/register",
                data: {"username": username, "password": password, "repassword": repassword, "code": code},
                type: "post",
                dataType: "json",
                success: function (data) {
                    if (data.code == 0) {
                        if (data.action) {
                            layer.msg(data.msg);
                            setTimeout(function () {
                                window.location.href = data.action;
                            }, 300)
                        }
                    } else {
                        layer.msg(data.msg);
                    }
                }
            })
        }
        
        //发送验证码按钮
        function sendCode() {
            
        }
    })
</script>
</html>